feat(workflow-controller): coordinate one workflow run - #107
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| } | ||
|
|
||
| const taskIds = requireStep(run, 'first-frame').candidateTaskIds | ||
| const terminals = await Promise.all( |
There was a problem hiding this comment.
High: waitForTerminal subscribes only after it has already observed a non-terminal snapshot. If the generation completes in the gap between get() and subscribe(), that terminal event is missed and the promise can hang forever, which leaves start*/resume* calls stuck.
| nextType: WorkflowStepType, | ||
| updatedAt: string, | ||
| ): WorkflowRun { | ||
| return editCurrentRevision(run, updatedAt, (revision) => { |
There was a problem hiding this comment.
High: this helper advances the current revision without checking whether the run was interrupted meanwhile. interruptRun() only flips the run status, so an in-flight generation that finishes later can still move an interrupted workflow forward behind the user's back.
| if (current.status !== expectedRevisionStatus) return false | ||
| if (revisions.slice(0, -1).some((revision) => revision.status === 'active')) return false | ||
|
|
||
| // 运行中/已中断保留唯一当前步骤;终态不得继续挂着 active 步骤。 |
There was a problem hiding this comment.
Medium: the terminal-state check only looks for active steps. A completed run can still contain failed steps and pass validation, so corrupted or partially failed history can be hydrated/saved as if it were valid.
98daef0 to
2f73825
Compare
|
@fennoai 复审 |
Re-review ResultFound 1 issue on the updated PR.
Verification:
|
| * 调用、后者等待用户逐步点击。Controller 不识别入口,也不保存第二份流程模型。 | ||
| */ | ||
| export interface WorkflowController { | ||
| create(input: CreateWorkflowRunInput): Promise<WorkflowRun> |
There was a problem hiding this comment.
有基于这套接口试着写一下 UI(如 Quick Start)那边的代码吗,会长成什么样?
问这个主要是发现这个 controller 不仅提供了 getWorkflow 用于读取 WorkflowRun 数据,还会让每一个修改方法也都返回 WorkflowRun 数据;我不确定哪个是使用方主要的获取 workflow-run 数据的渠道
There was a problem hiding this comment.
另外上面 AI review comment 记得处理 & resolve 下
…tion-full-frame) - Replace template-candidate/action-generation with action-first-frame/action-full-frame - confirmCandidate → confirmFirstFrame - Update all state transitions and tests Co-Authored-By: Claude <noreply@anthropic.com>
82ad6e4 to
f603a04
Compare
目的
按导师确认的边界重建 WorkflowController:一个 Controller 实例只对应一条 WorkflowRun。entities 只提供纯数据与异步 CRUD;Controller 同时持有当前 Run 快照,并向 Quick Start 与 Workflow Editor 提供相同的业务方法。
当前设计
范围
本 PR 只包含:
不包含页面、Playtest、Publish、导出、后端实现或登录模块。此前误合入的重复目录和整包前后端快照均已移除。
验证
后端约束
如果 Generation 已创建、WorkflowRun 引用保存持续失败且用户立刻整页刷新,前端无法跨进程找回未绑定任务。要做到跨刷新绝对不重复,需要后端后续提供幂等键或原子创建/绑定能力;当前实现已经保证同一 Controller 生命周期内不会重复创建。
Depends on #86
Closes #106